<?php

namespace App\Http\Model\Api;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;
use App\Http\Model\AudioApi;
use App\Http\Model\Base;
use Exception;

class GiftAppoint extends Base
{
    protected $table = 'gift_appoint';
    protected $connection = "mysql_kkaudio";

    public function __construct(array $attributes = [])
    {
        parent::__construct($this->table, $attributes);
    }

    public static function getAppointGifts() {

        return static::where('type', 2)->get();
    }

    public static function getGifts() {
        return curl_request(env('KK_API_HOST').'/gift/get_love_rank', [
            'type' => 1,
            'gift_id' => 20
        ], 'urlencoded', 'GET');
    }

    public function giftLibrary() {
        return $this->belongsTo(GiftLibrary::class, 'gift_id', 'gift_id')->withDefault([
            'name' => ''
        ]);
    }
}